<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page contentType="text/html; charset=UTF-8" language="java"%>
<%@ taglib uri="http://struts.apache.org/tags-html"  prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-bean"  prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>
<%@page import="com.kcs.common.utils.commonUtils"%>
<%@page import="com.kcs.common.utils.PropsUtils"%>
<%@page import="com.kcs.common.utils.Constant"%>

<html>
<head>
<title>FX Margin - List Of Forward Contract</title>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script type="text/javascript" src="jsp/script/jquery/plugin/fancybox/jquery.easing-1.3.pack.js"></script>
<script type="text/javascript" src="jsp/script/jquery/plugin/fancybox/jquery.fancybox-1.3.4.js"></script>
<script type="text/javascript" src="jsp/script/jquery/plugin/fancybox/jquery.fancybox-1.3.4.pack.js"></script>   
<script type="text/javascript" src="jsp/script/jsDatePick.full.1.3.js"></script>   	 	 	
<script type="text/javascript" src="jsp/script/common.js"></script>  
<link rel="stylesheet" type="text/css" href="jsp/script/jquery/plugin/fancybox/jquery.fancybox-1.3.4.css"/>
<link rel="stylesheet" type="text/css" href="jsp/css/table.css"/>
<link rel="stylesheet" type="text/css" href="jsp/css/fxmarginStyle.css"/>
<link rel="stylesheet" type="text/css" href="jsp/css/jsDatePick_ltr.css" />

<script type="text/javascript">
	window.onload = function(){
		new JsDatePick({
			useMode:2,
			target:"inAsOfDate",
			dateFormat:"%d/%m/%Y"
			/*selectedDate:{				This is an example of what the full configuration offers.
				day:5,						For full documentation about these settings please see the full version of the code.
				month:9,
				year:2006
			},
			yearsRange:[1978,2020],
			limitToToday:false,
			cellColorScheme:"beige",
			dateFormat:"%m-%d-%Y",
			imgPath:"img/",
			weekStartDay:1*/
		});

	};

	//for popup customer //
	
	function onPopup(id, src, width, height){
		g_datacustomer = null;
		jQuery("#" + id + "_iframe").html("");
		src = "http://" + window.location.host + "/FxMargin/" + src + ".do?pAction=init";
		var html = "<center><iframe src='" + src +"' height='" + height +"px' width='" + width + "px' id='myIframe'></iframe></center>";

		jQuery("#" + id + "_iframe").html(html);

		openPopup(id);
		
	}

	function select(data){
		g_datacustomer = data;
	}
	
	function onCustomer(){
		/*	global variable 'g_datacustomer' is use	*/
		if(g_datacustomer != null){
			jQuery("#inCifNo").val(g_datacustomer.cifNo);
			jQuery("#inCustomerName").val(g_datacustomer.customerName);	
			jQuery.fancybox.close();
		}
		
	}
	
	function offCustomer(){
		jQuery.fancybox.close();
	}
	// for popup customer //

	function searchForwardContract(){
		var tranCode = document.getElementsByName("tranCode")[0];
		tranCode.value = "searchForwardContract";

		document.forms[0].submit();
	}

	function printForwardContractList(){
		var tranCode = document.getElementsByName("tranCode")[0];
		tranCode.value = "printForwardContractList";

		document.forms[0].submit();
	}

	function resetForm(){
		var tranCode = document.getElementsByName("tranCode")[0];
		tranCode.value = "resetForm";

		document.forms[0].submit();
	}
	

</script>

</head>
<body>
	<!-- HEADER MENU -->
	<%@ include	file="include/headerMenu.jsp"%> 
	
		<center>
			<div id="divListOfForwardContract" style="width:95%;">
				<html:form action="/ListOfForwardContractAction.do" style="margin:0px;">
				
					<html:hidden property="tranCode"/>
					
					<table class="MarginHeader" width="100%">
						<tr>
							<td width="100%" style="text-align:left;">
								List Of Forward Contract
							</td>
						</tr>
					</table>
					
					<table width="100%" border="0">
						<tr>
							<td>
								<table class="MarginCriteria" width="100%">
									<tr>
										<td width="30%" align="right" valign="bottom"><font color="red">* </font>CIF No.</td>
										<td width="12%" align="left" valign="bottom">
											<html:text styleId="inCifNo" property="inCifNo" readonly="true" style="background: #DDDDDD;" onkeydown="javascript: return false;"></html:text>
										</td>
										<td width="10%" align="right" valign="bottom">Customer Name</td>
										<td width="48%" align="left" valign="bottom">
											<html:text styleId="inCustomerName" property="inCustomerName" size="50" readonly="true" style="background: #DDDDDD;" onkeydown="javascript: return false;"></html:text>
											&nbsp;&nbsp;
											<img src="jsp/images/btn/glass_search.gif" style="width:30px;cursor:pointer;" onclick="onPopup('popupCustomer','PopupCustomerAction',700,540);" />
										</td>
									</tr>
									<tr>
										<td align="right">As of Date</td>
										<td colspan="3" align="left"><html:text styleId="inAsOfDate" property="inAsOfDate" maxlength="10"></html:text></td>
									</tr>
									<tr>
										<td colspan="4">
											<center>
												<input type="button" class="button" value="Search" onclick="searchForwardContract();"/>
												&nbsp;
												&nbsp;
												<input type="button" class="button" value="Reset" onclick="resetForm();"/>
											</center>
										</td>
									</tr>
								</table>
							</td>
						</tr>
						<tr>
							<td>
								<br/><br/><br/>
								<center>
									<%
										Object err = request.getAttribute(Constant.ERR_ATTR);
									
										if(err != null){
											%>
												<script type="text/javascript">
													alert("<%=err%>");
												</script>
											<%
										}else{
											%>
												<logic:present name="<%=Constant.SHOW_RESULT%>">
													<div class="MarginTable" >
														<display:table id="data" name="sessionScope.ListOfForwardContractActionForm.forwardContractList" requestURI="/ListOfForwardContractAction.do" pagesize="10" >
															<display:column property="rowNum" title="No" sortable="false" style="text-align:center;"/>
															<display:column property="dealId" title="Deal No."   sortable="false" style="text-align:left;"/>
															<display:column property="dayToMat" title="Days to Mat" sortable="false" style="text-align:right;"/>			
															<display:column property="matDate" title="Mat Date" sortable="false" style="text-align:center;"/>
															<display:column property="buySell" title="Client Buy/Sell" sortable="false" style="text-align:left;"/>
															<display:column property="ccyPair" title="CCY Pair" sortable="false" style="text-align:left;"/>
															<display:column property="fxRate" title="FX Rate" sortable="false" style="text-align:right;"/>
															<display:column property="amt1" title="Amt1" sortable="false" style="text-align:right;"/>
															<display:column property="amt2" title="Amt2" sortable="false" style="text-align:right;"/>
															<display:column property="imRequired" title="IM Required" sortable="false" style="text-align:right;"/>			
															<display:column property="mtmRate" title="MTM Rate" sortable="false" style="text-align:right;"/>
															<display:column property="unrealizedPL" title="Unrealized P/L (THB)" sortable="false" style="text-align:right;"/>
															<display:column property="dealStatus" title="Deal Status" sortable="false" style="text-align:left;"/>
															<display:column property="dealType" title="Deal Type" sortable="false" style="text-align:left;"/>
														</display:table>
													</div>
													
													<logic:notEmpty name="ListOfForwardContractActionForm" property="forwardContractList">
														<br/><br/><br/>
														<input type="button" class="button" style="width:200;" value="Export Excel" onclick="printForwardContractList();"/>
													</logic:notEmpty>
													
												</logic:present>
										<%}%>
										
									</center>
							</td>
						</tr>
					</table>
				
					<div style="display:none">
				        <div id="popupCustomer" style="width:710px;height: 600px">
				        	<div id="popupCustomer_iframe"></div>
							<table width="100%">
								<tr>
									<td width="33%" align="center">
										<input type="button" value="Ok" class="button" onclick="onCustomer();"/>
									</td>
									<td width="34%" align="center">
										<input type="button" value="Close" class="button" onclick="offCustomer();"/>
									</td>
								</tr>
							</table>
				        </div>
				    </div>
					<%@ include	file="include/footer.jsp"%> 	
					<%@ include	file="include/message.jsp"%> 

				</html:form>
			
			</div>
		</center>
</body>
</html>